// MyHtmlView.cpp : implementation file
//

#include "stdafx.h"
#include "MyRichEdit.h"
#include "MyHtmlView.h"


// CMyHtmlView

IMPLEMENT_DYNCREATE(CMyHtmlView, CHtmlView)

CMyHtmlView::CMyHtmlView()
{

}

CMyHtmlView::~CMyHtmlView()
{
}

void CMyHtmlView::DoDataExchange(CDataExchange* pDX)
{
	CHtmlView::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CMyHtmlView, CHtmlView)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_RBUTTONDOWN()
	ON_WM_CREATE()
END_MESSAGE_MAP()


// CMyHtmlView diagnostics

#ifdef _DEBUG
void CMyHtmlView::AssertValid() const
{
	CHtmlView::AssertValid();
}

void CMyHtmlView::Dump(CDumpContext& dc) const
{
	CHtmlView::Dump(dc);
}
#endif //_DEBUG


// CMyHtmlView message handlers


void CMyHtmlView::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
	// TODO: Add your message handler code here

}


void CMyHtmlView::OnRButtonUp(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

//	CHtmlView::OnRButtonUp(nFlags, point);
}


void CMyHtmlView::OnRButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

//	CHtmlView::OnRButtonDown(nFlags, point);
}
static HWND GetLastChild(HWND hwndParent)
{
	HWND hwnd = hwndParent;
	while (TRUE) {
		HWND hwndChild = ::GetWindow(hwnd, GW_CHILD);
		if (hwndChild==NULL)
			return hwnd;
		hwnd = hwndChild;
	}
	return NULL;
}




void CMyHtmlView::OnNavigateComplete2(LPCTSTR strURL)
{
	// TODO: Add your specialized code here and/or call the base class
// 	HWND hWnd = GetLastChild(this->m_hWnd);
// 	if (hWnd)
// 	{
// 		myIEWnd->SubclassWindow(hWnd);
// 	}
	
	CHtmlView::OnNavigateComplete2(strURL);
}


int CMyHtmlView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CHtmlView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	myIEWnd = new CMyIEWnd();
	myIEWnd->Create(NULL, L"aaa", WS_CHILD, CRect(0,0,1,1), this, 12321);
	myIEWnd->ShowWindow(SW_HIDE);
	return 0;
}
